﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Service
{
    internal class WithDrawAmount : ICommand
    {
        DataLayer.DBFacade DB;
        Model.Account account;
        int amount;
        public WithDrawAmount(Model.Account account, int amount)
        {
            DB = new DataLayer.DBFacade();
            this.account = account;
            this.amount = amount;
        }
        public bool Execute()
        {
            string query = "SP_Withdraw 'W',"+account.AccountNumber+","+account.PIN+","+amount;
            return DB.Execute(query) > 0;
        }

        public bool Undo()
        {
            string query = "SP_Withdraw 'D'," + account.AccountNumber + "," + account.PIN + "," + amount;
            return DB.Execute(query) > 0;
        }
    }
}